import tools from "./tools.js";
import http from "http";
export default class Server {
  constructor({ port, directory }) {
    this.ips = tools.getLocalIp();
    this.port = port;
    this.directory = directory;
    this.createServer();
  }
  requestCallback = (req, res) => {
    this.req = req;
    this.res = res;
    console.log(this.req.url);
    console.log(this.req.method);
    this.res.end();
  };
  createServer = () => {
    const server = (this.server = http.createServer(this.requestCallback));
    server.listen(this.port, () => {
      console.log(
        `server startup in ${this.ips
          .map((v) => "\r\n" + "http://" + v + ":" + this.port)
          .join("")}`
      );
    });
  };
}
